package com.yanqu.road.logic.pb;

import com.yanqu.road.entity.player.UserCouponItem;
import com.yanqu.road.pb.recharge.CouponProto;

import java.util.List;

public class CouponPb {
    public static CouponProto.CouponItemTempMsg.Builder parseCouponItemTempMsg(UserCouponItem data){
        if(null == data){
            return null;
        }
        CouponProto.CouponItemTempMsg.Builder msg = CouponProto.CouponItemTempMsg.newBuilder();
        msg.setItemId(data.getItemId());
        msg.setGoodsId(data.getGoodsId());
        msg.setGetTime(data.getGetTime());
        msg.setExpirationTime(data.getExpirationTime());
        msg.setIsUse(data.isUse());
        return msg;
    }

    public static CouponProto.CouponItemListMsg.Builder parseCouponItemListMsg(List<UserCouponItem> dataList){
        CouponProto.CouponItemListMsg.Builder listMsg = CouponProto.CouponItemListMsg.newBuilder();
        if(null != dataList){
            for(UserCouponItem data : dataList){
                CouponProto.CouponItemTempMsg.Builder msg = parseCouponItemTempMsg(data);
                if(null != msg){
                    listMsg.addDataList(msg);
                }
            }
        }
        return listMsg;
    }
}
